package org.jeecg.modules.inspection.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.jeecg.modules.inspection.entity.ExceptionProcess;
import org.jeecg.modules.inspection.entity.PinspectionException;
import org.jeecg.modules.system.entity.SysUserPosition;
import org.springframework.stereotype.Repository;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;


/**
 * @Description: 巡检运行异常
 * @Author: jeecg-boot
 * @Date:   2019-09-26
 * @Version: V1.0
 */
@Repository
public interface PinspectionExceptionMapper extends BaseMapper<PinspectionException> {
    @Select("select parent_id from sys_depart where id = #{departId} AND del_flag = '0'")
    String selectOffice(@Param("departId")String departId);
    List<SysUserPosition> selectAllConfigUser(@Param("userLists") List<String> userLists,@Param("officeId") String officeId,@Param("userId") String userId);
    List<PinspectionException> selectExpection(@Param("itemIds")List<String> itemIds);
    List<PinspectionException> selectDealExpection(@Param("userId")String userId);
    @Select("select * from process_inspection_exception where process_item_id = #{pitemId} and process_area_id=#{areaId} and del_flag = '0'")
    PinspectionException selectExce(@Param("pitemId")String pitemId,@Param("areaId")String areaId);

    Integer updateStatus(PinspectionException pinspectionException);
    @Update("update process_inspection_exception set deal_contents=#{dealContents},handle_picture=#{handlePicture},handle_res=#{handleRes} where id=#{id} and del_flag='0'")
    Integer insertDealContents(PinspectionException pinspectionException);
    List<PinspectionException> selectAllExce(@Param("officeId")String officeId,@Param("typeList")List<String> typeList);
    @Update("update process_inspection_exception set comfirm_res ='2' where id =#{id} and del_flag='0'")
    Integer updateConfirm(@Param("id")String id);
    List<PinspectionException> selectByUser(@Param("userId")String userId,@Param("officeId")String officeId);
    Integer insertProcess(ExceptionProcess exceptionProcess);

    Integer updateExce(@Param("trueItems") List<String> trueItems);

    @Select("select * from process_inspection_exception where process_item_id = #{itemId} AND del_flag = '0'")
    List<PinspectionException> queryByItemId(@Param("itemId")String itemId);
    @Select("select * from process_inspection_exception where process_item_id =#{processItemId} and del_flag = '0'")
    List<PinspectionException> queryExceptionList(@Param("processItemId") String processItemId);
    @Select("select * from process_inspection_exception where allot_user=#{userId} AND del_flag = '0'")
    List<PinspectionException> selectCurrentAllot(@Param("userId") String userId);
}
